import 'package:flutter/material.dart';
import '../constants.dart' show AppColors, Constants;

class FullWidthButton extends StatelessWidget {
  static const HORIZONTAL_PADDING = 20.0;
  static const VERTICAL_PADDING = 13.0;

  final String iconPath;
  final String title;
  final bool showDivider;
  final VoidCallback onPressed;

  const FullWidthButton(
      {@required this.iconPath,
      @required this.title,
      this.showDivider: false,
      @required this.onPressed})
      : assert(iconPath != null),
        assert(title != null),
        assert(onPressed != null);

  @override
  Widget build(BuildContext context) {
    final pureButton = Container(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            child: Image.asset(iconPath),
            width: Constants.FullWidthIconButtonIconSize,
            height: Constants.FullWidthIconButtonIconSize,
          ),
          SizedBox(width: 20.0),
          Expanded(
            child: Text(
              title,
              style: TextStyle(fontSize: 16.0),
            ),
          ),
          Container(
            width: Constants.FullWidthIconButtonIconSize,
            height: Constants.FullWidthIconButtonIconSize,
            child: Icon(
              Icons.chevron_right,
              color: Colors.grey,
            ),
          )
        ],
      ),
      padding: const EdgeInsets.only(bottom: 13.0),
    );

    final borderedButton = Container(
      decoration: BoxDecoration(
          border: Border(
              bottom: BorderSide(
                  color: Color(AppColors.DividerColor),
                  width: Constants.DividerWidth))),
      child: pureButton,
    );

    return FlatButton(
      onPressed: onPressed,
      color: Colors.white,
      padding: EdgeInsets.only(
        left: 20.0,
        right: 10.0,
        top: 13.0,
      ),
      child: this.showDivider ? borderedButton : pureButton,
    );
  }
}
